package com.papper.common.enums;

/**
 * @Author:Lajiao
 * @Date:2014年7月14日
 * @Time:下午3:49:44
 * @Description:银行卡类型
 */
public enum CardTypeEnum {
    Debit(1, "储蓄卡", "0"),
    Credit(2, "信用卡", "1"),
    PrepaidCard(3, "预付费卡", "2"),
    ALIPAY(4, "支付宝账户", "4"),
    Compay(9, "对公账户", "9"),
    UNKOWN(8, "未知属性", "8");

    private Integer code;
    private String  name;
    private String  reapalType;

    CardTypeEnum(Integer code, String name, String reapalType) {
        this.code = code;
        this.name = name;
        this.reapalType = reapalType;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getReapalType() {
        return reapalType;
    }

    public void setReapalType(String reapalType) {
        this.reapalType = reapalType;
    }

    public static String getName(Integer code) {
        if (code == null) {
            return "";
        }
        for (CardTypeEnum re : CardTypeEnum.values()) {
            if (re.getCode().equals(code)) {
                return re.getName();
            }
        }
        return "";
    }

    public static Integer getCode(String name) {
        if (name == null) {
            return null;
        }
        for (CardTypeEnum re : CardTypeEnum.values()) {
            if (name.equals(re.getName())) {
                return re.getCode();
            }
        }
        return null;
    }

    public static Integer getCodeByReapal(String reapalType) {
        if (reapalType == null) {
            return null;
        }
        for (CardTypeEnum re : CardTypeEnum.values()) {
            if (reapalType.equals(re.getReapalType())) {
                return re.getCode();
            }
        }
        return null;
    }
}
